#ifndef TERRAINEFFECTS_H
#define TERRAINEFFECTS_H

#include "d3dUtil.h"
#include "ResourcesManager.h"
#include "VertexFormat.h"

namespace Effect
{
	class TerrainEffects
	{
	public:
		TerrainEffects();
		~TerrainEffects();

		void Init(ID3D10Device* device);

		//draw the terrain
		void BeginDraw();
		void Draw(UINT numFaces);

		//set xx method
		void SetVertexBuffer(ID3D10Buffer* buffer);
		void SetIndexBuffer(ID3D10Buffer* buffer);

		void SetDirectionToSun(const D3DXVECTOR4& dir);

		void SetWVPMatrix(const D3DXMATRIX& mat);
		void SetWorldMatrix(const D3DXMATRIX& mat);

		void SetLayer0(ID3D10ShaderResourceView* resView);
		void SetLayer1(ID3D10ShaderResourceView* resView);
		void SetLayer2(ID3D10ShaderResourceView* resView);
		void SetLayer3(ID3D10ShaderResourceView* resView);
		void SetLayer4(ID3D10ShaderResourceView* resView);
		void SetBlendMap(ID3D10ShaderResourceView* resView);

	private:
		void BuildFX();
		void BuildVertexLayouts();
	private:
		ID3D10Device* m_pDevice;
		ID3D10Effect* m_pFx;
		ID3D10InputLayout* m_pInputLayout;

		ID3D10EffectTechnique* m_pFxTech;
		ID3D10EffectMatrixVariable* m_pFxWVPVar;
		ID3D10EffectMatrixVariable* m_pFxWorldVar;
		ID3D10EffectVectorVariable* m_pFxDirToSunVar;
		ID3D10EffectShaderResourceVariable* m_pFxLayer0Var;
		ID3D10EffectShaderResourceVariable* m_pFxLayer1Var;
		ID3D10EffectShaderResourceVariable* m_pFxLayer2Var;
		ID3D10EffectShaderResourceVariable* m_pFxLayer3Var;
		ID3D10EffectShaderResourceVariable* m_pFxLayer4Var;
		ID3D10EffectShaderResourceVariable* m_pFxBlendMapVar;
	};
}

#endif